This repository has been archived by the owner on Jan 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
jaggr-web and non-osgi sample - Implementation of review comments #199
Open
projsaha
wants to merge
1
commit into
OpenNTF:master
Choose a base branch
from
projsaha:jaggrweb
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Manifest-Version: 1.0 | ||
Class-Path: | ||
|
19 changes: 19 additions & 0 deletions
19
jaggr-web/src/META-INF/services/com.ibm.jaggr.core.modulebuilder.IModuleBuilder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# (C) Copyright 2012, IBM Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
com.ibm.jaggr.core.impl.modulebuilder.i18n.I18nModuleBuilder | ||
com.ibm.jaggr.core.impl.modulebuilder.javascript.JavaScriptModuleBuilder | ||
com.ibm.jaggr.core.impl.modulebuilder.css.CSSModuleBuilder | ||
com.ibm.jaggr.core.impl.modulebuilder.text.TextModuleBuilder | ||
com.ibm.jaggr.core.impl.modulebuilder.less.LessModuleBuilder |
20 changes: 20 additions & 0 deletions
20
jaggr-web/src/META-INF/services/com.ibm.jaggr.core.resource.IResourceFactory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# (C) Copyright 2012, IBM Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
com.ibm.jaggr.core.impl.resource.FileResourceFactory | ||
com.ibm.jaggr.core.impl.resource.ClasspathResourceFactory | ||
com.ibm.jaggr.core.impl.resource.JarResourceFactory | ||
|
||
|
||
|
15 changes: 15 additions & 0 deletions
15
jaggr-web/src/META-INF/services/com.ibm.jaggr.core.transport.IHttpTransport
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# (C) Copyright 2012, IBM Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
com.ibm.jaggr.web.impl.transport.DojoHttpTransport |
123 changes: 123 additions & 0 deletions
123
jaggr-web/src/com/ibm/jaggr/web/PlatformServicesImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
/* | ||
* � Copyright IBM Corp. 2013 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at: | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
* implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package com.ibm.jaggr.web; | ||
|
||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
import java.net.URL; | ||
import java.util.ArrayList; | ||
import java.util.Dictionary; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
import com.ibm.jaggr.core.IPlatformServices; | ||
import com.ibm.jaggr.core.IServiceReference; | ||
import com.ibm.jaggr.core.IServiceRegistration; | ||
|
||
public class PlatformServicesImpl implements IPlatformServices { | ||
|
||
private Map<String, Object> serviceReferenceMap; | ||
|
||
public PlatformServicesImpl() { | ||
//But this will be a problem if we ever try to support a command console | ||
//because the console communicates with the aggregator instances that are registered in the service registry, | ||
//and for that to work, the service registry has to be a global object. | ||
serviceReferenceMap = new ConcurrentHashMap<String, Object>(); | ||
} | ||
|
||
@Override | ||
public IServiceRegistration registerService(String clazz, Object service, Dictionary<String, String> properties) { | ||
StringBuilder sb = new StringBuilder(); | ||
String uniqueKey = sb.append(clazz).append("_") //$NON-NLS-1$ | ||
.append(service.getClass().getName()).toString(); | ||
if (!serviceReferenceMap.containsKey(uniqueKey)) { | ||
Object[] serviceDetails = new Object[3]; | ||
serviceDetails[0] = clazz; | ||
serviceDetails[1] = service; | ||
serviceDetails[2] = properties; | ||
serviceReferenceMap.put(uniqueKey, serviceDetails); | ||
} | ||
IServiceRegistration serviceRegistation = new ServiceRegistrationWeb(uniqueKey, this); | ||
|
||
return serviceRegistation; | ||
} | ||
|
||
|
||
public void unRegisterService(Object serviceRegistration) { | ||
if (serviceReferenceMap.containsKey((String) serviceRegistration)) { | ||
serviceReferenceMap.remove((String) serviceRegistration); | ||
return; | ||
} | ||
} | ||
|
||
@Override | ||
public IServiceReference[] getServiceReferences(String clazz, String filter) { | ||
return getServiceReferences(clazz); | ||
} | ||
|
||
public IServiceReference[] getServiceReferences(String clazz) { | ||
ArrayList<IServiceReference> serviceReferences = new ArrayList<IServiceReference>(); | ||
Set<String> srs = serviceReferenceMap.keySet(); | ||
for(String sr : srs){ | ||
int index = ((String) sr).indexOf("_"); //$NON-NLS-1$ | ||
String clz = ((String) sr).substring(0, index); | ||
if(clz.equalsIgnoreCase(clazz) || clazz == null){ | ||
serviceReferences.add(new ServiceReferenceWeb(sr)); | ||
} | ||
} | ||
IServiceReference[] serviceRefs = new IServiceReference[serviceReferences.size()]; | ||
for(int i = 0; i < serviceReferences.size(); i++){ | ||
serviceRefs[i] = serviceReferences.get(i); | ||
} | ||
return serviceRefs; | ||
} | ||
|
||
@Override | ||
public Object getService(IServiceReference serviceReference) { | ||
Object[] serviceDetails = null; | ||
serviceDetails = (Object[])(serviceReferenceMap.get((String)serviceReference.getPlatformObject())); | ||
return serviceDetails[1]; | ||
} | ||
|
||
@Override | ||
public synchronized boolean ungetService(IServiceReference serviceReference) { | ||
boolean status = false; | ||
if(serviceReferenceMap.containsKey((String)serviceReference.getPlatformObject())){ | ||
serviceReferenceMap.remove((String)serviceReference.getPlatformObject()); | ||
status = true; | ||
return status; | ||
} | ||
return status; | ||
} | ||
|
||
@Override | ||
public URL getResource(String resourceName) { | ||
return null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that this should return getAppContextURI().resolve(resourceName). |
||
} | ||
|
||
@Override | ||
public Dictionary<String, String> getHeaders() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public URI getAppContextURI() throws URISyntaxException { | ||
return null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could this return new URI("classpath:///");. That would make it possible to use URIs like "/WebContent/..." instead of "classpath:///WebContent/..." in aggrConfig.js (see AbstractAggregatorImpl.newResource() when URI is not absolute). |
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* � Copyright IBM Corp. 2013 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at: | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
* implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package com.ibm.jaggr.web; | ||
|
||
import com.ibm.jaggr.core.IServiceReference; | ||
|
||
public class ServiceReferenceWeb implements IServiceReference { | ||
|
||
String serviceReference = null; | ||
|
||
|
||
public ServiceReferenceWeb(String serviceRef){ | ||
serviceReference = serviceRef; | ||
} | ||
|
||
@Override | ||
public Object getPlatformObject(){ | ||
return serviceReference; | ||
|
||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
jaggr-web/src/com/ibm/jaggr/web/ServiceRegistrationWeb.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* � Copyright IBM Corp. 2013 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at: | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
* implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package com.ibm.jaggr.web; | ||
|
||
import com.ibm.jaggr.core.IServiceRegistration; | ||
|
||
public class ServiceRegistrationWeb implements IServiceRegistration { | ||
|
||
String ServiceRegistration = null; | ||
PlatformServicesImpl platformServices = null; | ||
|
||
public ServiceRegistrationWeb(String serviceRegistrationWeb, PlatformServicesImpl platformServicesWeb){ | ||
ServiceRegistration = serviceRegistrationWeb; | ||
platformServices = platformServicesWeb; | ||
} | ||
|
||
@Override | ||
public void unregister() { | ||
platformServices.unRegisterService(ServiceRegistration); | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To use ConcurrentMap in a thread-safe way, you need to use the putIfAbsent() method instead of containsKey() to add a key to the map only if it is not already there.