@Override public Connector createNewInstance(String id) { VirtualType handler = createNewHandler(id); Connector newProxyInstance = (Connector) Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class<?>[]{ domainProvider.getDomainInterface(), Connector.class }, handler); handlers.put(newProxyInstance, handler); return newProxyInstance; }
private void finishCreatingInstance(ConnectorId id, ConnectorDescription description, DomainProvider domainProvider, ConnectorInstanceFactory factory) { Connector serviceInstance = factory.createNewInstance(id.toString()); if (serviceInstance == null) { throw new IllegalStateException("Factory cannot create a new service for instance id " + id.toString()); } factory.applyAttributes(serviceInstance, description.getAttributes()); serviceInstance.setDomainId(id.getDomainType()); serviceInstance.setConnectorId(id.getConnectorType()); String[] clazzes = new String[]{ OpenEngSBService.class.getName(), Domain.class.getName(), domainProvider.getDomainInterface().getName(), }; Map<String, Object> properties = populatePropertiesWithRequiredAttributes(description.getProperties(), id); ServiceRegistration serviceRegistration = bundleContext.registerService(clazzes, serviceInstance, MapAsDictionary.wrap(properties)); registrations.put(id, serviceRegistration); instances.put(id, serviceInstance); }